home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Discy Business / Discy Business.2mg / DEV.CD / GUIDED.TOURS / IIC.PLUS.TOUR / BASIC / NUMERIC1.TEXT < prev    next >
Encoding:
Text File  |  1988-05-01  |  3.2 KB  |  233 lines  |  [04] ASCII Text (0x0000)

  1. %
  2. 3
  3. 14
  4. 1
  5. 38
  6.      ALL ABOUT VARIABLES
  7.  
  8. Since you're a curious person
  9. (after all, you made it this far),
  10. you're probably wondering how the
  11. computer asks for and remembers
  12. your name. Stay tuned.  This
  13. section will teach you how that's
  14. done.
  15. ^
  16. %
  17. 20
  18. 24
  19. 1
  20. 38
  21. The computer's memory is a lot
  22. like hundreds of mailboxes.
  23. ^
  24. &
  25. Each mailbox can contain
  26. different information.
  27. ^
  28. &
  29. And each mailbox has a name that
  30. sets it apart from other boxes.
  31. ^
  32. &
  33. These mailboxes in memory are
  34. called variables.
  35. ^
  36. &
  37. And the name given to each box in
  38. memory is called a variable name.
  39. ^
  40. %
  41. 3
  42. 10
  43. 1
  44. 38
  45. A variable name is made up of
  46. letters and numbers.  For this
  47. example, we've chosen the name A
  48. (which just happens to stand for
  49. Apple).
  50. ^
  51. %
  52. 3
  53. 12
  54. 1
  55. 38
  56. For the variable A to be of any
  57. use to you, you must assign
  58. some information to it.  The
  59. question is, how do you assign
  60. information--such as numbers,
  61. words, or equations (like 3+4)--to
  62. a variable?
  63. ^
  64. &
  65. One way to do this is to use
  66. the LET statement.  The LET
  67. statement assigns information
  68. (in this case a number)
  69. to the variable.
  70. ^
  71. %
  72. 3
  73. 7
  74. 1
  75. 38
  76. The LET statement looks like
  77. this...
  78. ^
  79. %
  80. 3
  81. 7
  82. 1
  83. 38
  84. First, you must type a line
  85. number.  In this case, line 10.
  86. ^
  87. &
  88. Next, you type LET...
  89. ^
  90. &
  91. followed by the variable name.
  92. In this case, A.
  93. ^
  94. &
  95. The next step is to type an equal
  96. sign (=).
  97. ^
  98. &
  99. Then type the number you want
  100. to assign to the variable.
  101. ^
  102. %
  103. 3
  104. 10
  105. 1
  106. 38
  107. The number 33 is now stored under
  108. the name A.  Now instead of asking
  109. the Apple II to print 33, you
  110. can ask it to PRINT the contents
  111. of A, which is 33.
  112. ^
  113. &
  114. Do you know what to type to tell
  115. the computer to print the contents
  116. of A?  If so, type it now on line
  117. 20.  (If you're not sure what to
  118. do now, press RETURN for a hint.)
  119. ^
  120. %
  121. 3
  122. 8
  123. 1
  124. 38
  125. You did it!  To complete your
  126. three-line program, type an END
  127. statement on line 30.
  128. ^
  129. %
  130. 3
  131. 9
  132. 1
  133. 38
  134. You're becoming a first-rate
  135. programmer!  Now run the program
  136. and look at the result of your
  137. work.
  138. ^
  139. %
  140. 3
  141. 10
  142. 1
  143. 38
  144. Congratulations!  You've just
  145. written a program using variables.
  146. Would you like a bit more
  147. explanation of how this program
  148. works? (Y/N)
  149. ^
  150. %
  151. 3
  152. 10
  153. 1
  154. 38
  155. Variables are somewhat exclusive
  156. in that they hold only one thing
  157. at a time.  If you assign a new
  158. value to the variable A, the
  159. old value is replaced.
  160. ^
  161. &
  162. Try it yourself.  Replace the
  163. old LET statement on line 10 with
  164. a new one and assign different
  165. contents to A.
  166. ^
  167. %
  168. 3
  169. 7
  170. 1
  171. 38
  172. Now run the program and notice
  173. the new contents of A.
  174. ^
  175. %
  176. 3
  177. 10
  178. 1
  179. 38
  180. See, we weren't kidding.  The
  181. contents of variable A changed
  182. from 33 to
  183. ^
  184. &
  185. There are two ways to assign
  186. information to variables.  You
  187. just learned how to assign
  188. something to a variable inside a
  189. program.
  190. ^
  191. &
  192. One way to change the contents
  193. is to rewrite the LET statements
  194. whenever you want to change the
  195. numbers.
  196. ^
  197. %
  198. 3
  199. 10
  200. 1
  201. 38
  202. The second way is to let you
  203. enter information from the
  204. keyboard while the program is
  205. running.  This involves using the
  206. INPUT statement.
  207. ^
  208. %
  209. 3
  210. 9
  211. 1
  212. 38
  213. First of all, please clear the
  214. computer's memory.  (Press RETURN
  215. for a hint if you're not sure of
  216. what to do.)
  217. ^
  218. %
  219. 3
  220. 9
  221. 1
  222. 38
  223. Good job.  You're doing well.
  224. We've taken the liberty of writing
  225. a number game program to help
  226. explain the INPUT statement.
  227. ^
  228. &
  229. We saved the program on the disk
  230. under the name NUMBER. Please
  231. load the NUMBER program now.
  232. ^
  233.